﻿using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.ScheduleJob.SPI
{
    public class UserDefineQueryFilter
    {
        private Dictionary<string, object> filter = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
        public UserDefineQueryFilter(Dictionary<string, object> f)
        {
            filter = new Dictionary<string, object>(f);
        }
        public UserDefineQueryFilter()
        { }
        public void Add(string key, object value)
        {
            if (filter == null)
                filter = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
            filter[key] = value;
        }
        public object GetData(string key)
        {
            if (ContainsKey(key))
                return filter[key];
            return null;
        }
        public string GetStringData(string key)
        {
            var obj = GetData(key);
            return Convert.ToString(obj);
        }

        public int Count
        {
            get
            {
                if (filter == null)
                    return 0;
                else
                    return filter.Count;
            }
        }
        public bool ContainsKey(string key)
        {
            if (filter == null || filter.Count <= 0)
                return false;
            if (filter.ContainsKey(key))
                return true;
            return false;
        }
    }
}
